# -*- coding: utf-8 -*-
# @Time    : 2019/10/21 10:30
# @Author  : XuHaoTang
# @File    : notetest.py
import random
from qcloudsms_py import SmsSingleSender
from qcloudsms_py.httpclient import HTTPError

appid = 1400207315
appkey = "82922343b194b2f445f44aaf04ec840d"
phone_numbers = ["15808201361"]
template_id = 323066
sms_sign = "腾讯云"

ssender = SmsSingleSender(appid, appkey)
verification_code = str(random.randint(1000, 9999))
params = [verification_code, '3']  # 当模板没有参数时，`params = []`
try:
    result = ssender.send_with_param(86, phone_numbers[0],
                                     template_id, params, sign=sms_sign, extend="", ext="")
except HTTPError as e:
    print(e)
except Exception as e:
    print(e)
print(result)